import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        //"hello".charAt(2);
        String [] arr1 = new String[100];
        int[] arr2 = new int[num];
        char[] arr3 = new char[num];
        for (int i = 0; i < num; i++) {
            String str = sc.next();
            arr1[i] = str;
            arr2[i] = str.length();
            arr3[i] = str.charAt(0);
        }
        int flag1 = 1;
        int flag2 = 1;
        for (int i = 0; i < num-1; i++) {
            if (arr2[i]>arr2[i+1]) {
                flag1 = 0;
            }
            if (arr3[i]>arr3[i+1]) {
                flag2 = 0;
            }
        }
        if (flag1 ==0 && flag2 == 1) {
            System.out.println("lexicographically");
        }else if (flag1 == 1 && flag2 == 0) {
            System.out.println("lengths");
        }else if(flag1 == 0 && flag2 == 0){
            System.out.println("none");
        }else {
            System.out.println("both");
        }
        System.out.println();
    }

}
